<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"  xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j">
	<c:choose>
		<c:when test="#{cart.products.isEmpty()}">
								<div id="navi">
						<span>
							<h:graphicImage value="/resources/image/homeicon.jpg" alt="image" width="15" height="15"/>
							<h:outputLink value="index.xhtml" class="navi_button">Back to Entry</h:outputLink>
						</span>
						|
						<span>
							<h:graphicImage value="/resources/image/searchicon.jpg" alt="image" width="15" height="15"/>
							<h:outputLink value="customerSearchOrder.xhtml" class="navi_button">Search Purchases</h:outputLink>
						</span>
						|
						<span>
							<h:outputLink value="browse.xhtml" class="navi_link">Browse</h:outputLink>
						</span>

					</div>
			Illegal Request
		</c:when>
		<c:otherwise>
			<div id="container">
				<h:form>
					<div id="navi">
						<span>
							<h:graphicImage value="/resources/image/searchicon.jpg" alt="image" width="15" height="15"/>
							<h:outputLink value="index.xhtml" class="navi_button">Back to Entry</h:outputLink>
						</span>
						|
						<span>
							<h:graphicImage value="/resources/image/searchicon.jpg" alt="image" width="15" height="15"/>
							<h:outputLink value="customerSearchOrder.xhtml" class="navi_button">Search Purchases</h:outputLink>
						</span>
						|
						<span>
							<h:outputLink value="browse.xhtml" class="navi_link">Browse</h:outputLink>
						</span>
						>
						<span>
							<h:outputLink value="cart.xhtml" class="navi_link">Shopping Cart</h:outputLink>
						</span>
						>
						<span class="navi_current">
							Check Out
						</span>
						>
						<span>
							<h:outputLink value="confirm.xhtml" class="navi_link">Confirm</h:outputLink>
						</span>
						>
						<span class="navi_future">Finish</span>
					</div>
					<div id="checkout_decoration">
						
					</div>
					<div id="checkout_content">
						<div class="content_head">
							<span>Customer Information</span>
						</div>
						<div class="content_body">
							<rich:collapsiblePanel header="Name" switchType="client" style="text-align: left;">
								<h:panelGrid columns="4">
									<span class="form_item">
										<h:outputText value="Title:" />
										<rich:select id="checkout_input_title" value="#{checkOut.currentPersonTitle}" converter="#{aip.assignment2.view.converter.PersonTitleConverter}" required="true" styleClass="checkout_select_title" listWidth="70">
											<c:forEach items="#{checkOut.personTitles}" var="personTitle">
												<f:selectItem itemValue="#{personTitle}" itemLabel="#{personTitle.name}" />
											</c:forEach>
										</rich:select>
										<rich:message for="checkout_input_title" />
									</span>
									<span class="form_item">
										<h:outputText value="Surname:" />
										<rich:inplaceInput id="checkout_input_surname" required="true" defaultLabel="click to enter your surname" value="#{checkOut.currentSurname}" />
										<rich:message for="checkout_input_surname" />
									</span>
									<span class="form_item">
										<h:outputText value="Given Name:" />
										<rich:inplaceInput id="checkout_input_given_name" required="true" defaultLabel="click to enter your given name" value="#{checkOut.currentGivenName}" />
										<rich:message for="checkout_input_given_name" />
									</span>
								</h:panelGrid>
							</rich:collapsiblePanel>
							<rich:collapsiblePanel header="Email" switchType="client" style="text-align: left;">
								<rich:inplaceInput id="checkout_input_email" required="true" defaultLabel="click to enter your email address" value="#{checkOut.currentEmail}" validatorMessage="Email format is invalid.">
									<f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />
								</rich:inplaceInput>
								<rich:message for="checkout_input_email" />
							</rich:collapsiblePanel>
							<rich:collapsiblePanel header="Address" switchType="client" style="text-align: left;">
								<h:panelGrid columns="4">
									<span class="form_item">
										<h:outputText value="Unit/House Number:" />
										<rich:inplaceInput id="checkout_input_number" required="true" defaultLabel="click to enter your unit/house number" value="#{checkOut.currentNumber}" />
										<rich:message for="checkout_input_number" />
									</span>
									<span class="form_item">
										<h:outputText value="Street:" />
										<rich:inplaceInput id="checkout_input_street" required="true" defaultLabel="click to enter your street" value="#{checkOut.currentStreet}" />
										<rich:message for="checkout_input_street" />
									</span>
									<span class="form_item">
										<h:outputText value="Suburb:" />
										<rich:inplaceInput id="checkout_input_suburb" required="true" defaultLabel="click to enter your suburb" value="#{checkOut.currentSuburb}" />
										<rich:message for="checkout_input_suburb" />
									</span>
									<span class="form_item">
										<h:outputText value="State:" />
										<rich:inplaceInput id="checkout_input_state" required="true" defaultLabel="click to enter your state" value="#{checkOut.currentState}" />
										<rich:message for="checkout_input_state" />
									</span>
									<span class="form_item">
										<h:outputText value="Postcode:" />
										<rich:inplaceInput id="checkout_input_postcode" required="true" defaultLabel="click to enter your postcode" value="#{checkOut.currentPostcode}" />
										<rich:message for="checkout_input_postcode" />
									</span>
									<span class="form_item">
										<h:outputText value="Country:" />
										<rich:select id="checkout_input_country" required="true" styleClass="checkout_select_country" value="#{checkOut.currentCountry}" converter="#{aip.assignment2.view.converter.CountryConverter}" listWidth="120">
											<c:forEach items="#{checkOut.countries}" var="country">
												<f:selectItem itemValue="#{country}" itemLabel="#{country.name}" />
											</c:forEach>
										</rich:select>
										<rich:message for="checkout_input_country" />
									</span>
								</h:panelGrid>
							</rich:collapsiblePanel>
							<rich:collapsiblePanel header="Credit Card" switchType="client" style="text-align: left;">
								<h:panelGrid columns="4">
									<span class="form_item">
										<h:outputText value="Type:" />
										<rich:select id="checkout_input_card_type" value="#{checkOut.currentCreditCardType}" converter="#{aip.assignment2.view.converter.CreditCardTypeConverter}" required="true" styleClass="checkout_select_card_type" listWidth="100">
											<c:forEach items="#{checkOut.creditCardTypes}" var="creditCardType">
												<f:selectItem itemValue="#{creditCardType}" itemLabel="#{creditCardType.name}" />
											</c:forEach>
										</rich:select>
										<rich:message for="checkout_input_card_type" />
									</span>
									<span class="form_item">
										<h:outputText value="Number:" />
										<rich:inplaceInput id="checkout_input_card_number" required="true" defaultLabel="click to enter your credit card number" value="#{checkOut.currentCreditCardNumber}" />
										<rich:message for="checkout_input_card_number" />
									</span>
									<span class="form_item">
										<h:outputText value="Security Code:" />
										<rich:inplaceInput id="checkout_input_card_security_code" required="true" defaultLabel="click to enter your credit card security code" value="#{checkOut.currentCreditCardSecurityCode}" />
										<rich:message for="checkout_input_card_security_code" />
									</span>
									<span class="form_item">
										<h:outputText value="Expiry Month:" />
										<rich:inputNumberSpinner id="checkout_input_card_expiry_month" enableManualInput="false" value="#{checkOut.currentCreditCardExpiryMonth}" minValue="1" maxValue="12" />
										<rich:message for="checkout_input_card_expiry_month" />
									</span>
									<span class="form_item">
										<h:outputText value="Expiry Year:" />
										<rich:inputNumberSpinner id="checkout_input_card_expiry_year" enableManualInput="false" value="#{checkOut.currentCreditCardExpiryYear}" minValue="2012" maxValue="2020" />
										<rich:message for="checkout_input_card_expiry_year" />
									</span>
								</h:panelGrid>
							</rich:collapsiblePanel>
						</div>
					</div>
					<div class="footnav">
						<span><h:commandButton class="footnav_button" onclick="location.href='cart.xhtml'" value="&lt;&lt; Back" type="button" /></span>
						<span><h:commandButton class="footnav_button" action="confirm" value="Next &gt;&gt;" /></span>
					</div>
				</h:form>
			</div>
		</c:otherwise>
	</c:choose>
</ui:composition>
